package com.tangtang.gulimall.member.controller;

import com.tangtang.common.utils.R;
import com.tangtang.gulimall.member.entity.MemberEntity;
import com.tangtang.gulimall.member.feign.GetcouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class FeignController {
    //调用feign接口的服务
    @Autowired
    GetcouponService getcouponService;

    @RequestMapping("/feignClientgetCoupon")
    public R getCoupon()
    {
        System.out.println("有请求进入");
        MemberEntity memberEntity = new MemberEntity();
        memberEntity.setUsername("张三");
        R getcouponServiceCoupons = getcouponService.getCoupon();
        Object coupons = getcouponServiceCoupons.get("coupons");//这个coupons是远程服务端的优惠卷模块里面的
        System.out.println("获取的优惠卷为："+coupons);
        return R.ok().put("username",memberEntity).put("coupons",coupons);
    }
}
